package com.qf.contract.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.qf.common.base.exception.ServiceException;
import com.qf.common.base.result.ResultCode;
import com.qf.contract.entity.FAnnouncementTypeOfContract;
import com.qf.contract.mapper.FAnnouncementTypeOfContractMapper;
import com.qf.contract.service.FAnnouncementTypeOfContractService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 增删改查
 */
@Service
public class FAnnouncementTypeOfContractServiceImpl implements FAnnouncementTypeOfContractService {
    @Resource
    FAnnouncementTypeOfContractMapper fAnnouncementTypeOfContractMapper;

    @Override
    public int addFAnnouncementTypeOfContractService(FAnnouncementTypeOfContract fAnnouncementTypeOfContract) {
        try {
            return fAnnouncementTypeOfContractMapper.insert(fAnnouncementTypeOfContract);
        } catch (Exception e) {
            throw new ServiceException(ResultCode.SYS_ERROR);
        }
    }

    @Override
    public int delFAnnouncementTypeOfContractService(int id) {
        try {
            return fAnnouncementTypeOfContractMapper.deleteById(id);
        } catch (Exception e) {
            throw new ServiceException(ResultCode.SYS_ERROR);
        }
    }

    @Override
    public int upFAnnouncementTypeOfContractService(FAnnouncementTypeOfContract fAnnouncementTypeOfContract) {
        try {
            return fAnnouncementTypeOfContractMapper.updateById(fAnnouncementTypeOfContract);
        } catch (Exception e) {
            throw new ServiceException(ResultCode.SYS_ERROR);
        }
    }

    @Override
    public Page<FAnnouncementTypeOfContract> selectFAnnouncementTypeOfContractService(int current, int size) {
        try {
            Page<FAnnouncementTypeOfContract> fAnnouncementTypeOfContractPage = fAnnouncementTypeOfContractMapper.selectPage(new Page<>(current, size), null);
            return fAnnouncementTypeOfContractPage;
        } catch (Exception e) {
            throw new ServiceException(ResultCode.SYS_ERROR);
        }
    }
}
